<template>
	<view style="padding: 10px;">
		<view class="u-m-t-20">
			<u-cell-group>
				<u-cell-item icon="lock" title="修改密码" @click="pageActive('pages/user/views/change_pwd')"></u-cell-item>
			</u-cell-group>
		</view>
		<u-button @click="logout">退出登录</u-button>
		<u-modal v-model="show" :content="content" @confirm="confirm" show-cancel-button="true"></u-modal>
	</view>
</template>

<script>
	import {mapState,mapMutations} from 'vuex'
	export default {
		computed:mapState(['user', ]),
		data() {
			return {
				show: false,
				content: '确认退出登录？'
			}
		},
		methods:{
			...mapMutations(['setJwzls','setGzzs']),
			pageActive(path){
				this.$u.route(path);
			},
			logout(){
				console.log(this.user);
				this.show = true;
			},
			confirm(){
				var _this = this;
				this.$http.get("/check/logout").then(res=>{
					uni.removeStorage({
						key:'tokenId',
						success() {
							_this.setJwzls(null);
							uni.removeStorage({
								key:"userInfo",
								success() {
									uni.reLaunch({
									    url: '/pages/login/login'
									});
								}
							})
						}
					})
				})
				
			}
		}
	}
</script>

<style>
</style>
